package net.uman.service;

import java.util.List;

import net.uman.dao.BbsplateDao;
import net.uman.entity.Bbsplate;
import net.uman.framework.modules.orm.Page;
import net.uman.framework.modules.orm.PropertyFilter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BbsplateManager extends Manager {
	@Autowired
	private BbsplateDao bbsplateDao;
	
	public Page<Bbsplate> findBbsplatePage(Page<Bbsplate> page,List<PropertyFilter> filters){
		return bbsplateDao.findPage(page, filters);
	}

	public void save(Bbsplate bbsplate) {
		bbsplateDao.save(bbsplate);
	}

	public void deletePlate(Long plateId) {
		bbsplateDao.delete(plateId);
	}

	public Bbsplate getBbsplate(Long plateId) {
		return bbsplateDao.get(plateId);
	}

	public List<Bbsplate> getFrontPlates() {
		Page<Bbsplate> page_plate = new Page<Bbsplate>(6);
		page_plate.setPageNo(1);
		page_plate.setOrderBy("id");
		page_plate.setOrder(Page.DESC);
		return findBbsplatePage(page_plate, null).getResult();
	}
	
	/**
	 * 查询出所有的板块（但是不会太多）
	 * @author jinlong-dt
	 * @return
	 */
	public List<Bbsplate> getAllFrontPlates() {
		Page<Bbsplate> page_plate = new Page<Bbsplate>(100);
		page_plate.setPageNo(1);
		page_plate.setOrderBy("id");
		page_plate.setOrder(Page.DESC);
		return findBbsplatePage(page_plate, null).getResult();
	}
}
